<form class="form-horizontal pl-box">
    <input type="hidden"  name="server" id="serverText-value" value="1446"/>
    <input type="hidden"  name="game" value="<?php echo $model->game_id; ?>"/>
    <input type="hidden"  name="product_type" value="SKILL"/>
    <div class="control-group">
        <label class="control-label">Server Type:</label>
        <div class="controls">
            <select id="skill" name="skill" onchange="SetSkillData(this)">
                <?php
                $cdbc = new CDbCriteria;
                $cdbc->compare('game_id', $model->game_id);
                $cdbc->order = "order_sort ASC";
                $skData = ProductSkill::model()->findAll($cdbc);
                $initStart = $skData[0]->id;
                foreach ($skData as $sData) {
                    echo "<option value='" . $sData->id . "'>" . $sData->skill_name . "</option>";
                }
                ?>
            </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">Other Type:</label>
        <div class="controls">
            Attack:
            <select class="input-small" disabled="" name="attack_box" id="attack_box" onchange="SetSkillData()">
                <option value="1">Attack 1-19</option>
                <option value="2">Attack 20-39</option>
                <option value="4">Attack 40+</option>
            </select>
            Defence:
            <select class="input-small" disabled="" name="defence_box" id="defence_box" onchange="SetSkillData()">
                <option value="1">Defence 1-19</option>
                <option value="2">Defence 20-39</option>
                <option value="4">Defence 40+</option>
            </select>
            Strength:
            <select class="input-small" disabled="" name="strength_box" id="strength_box" onchange="SetSkillData()">
                <option value="1">Strength 1-19</option>
                <option value="2">Strength 20-39</option>
                <option value="4">Strength 40+</option>
            </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" style="line-height: 66px;">Power Level:</label>
        <div class="controls">
            <?php
            //获取最大，最小等级
            $mLevel = ProductSkillLevel::model()->getMaxMinLevel($initStart);
            $tmax = $mLevel->maxlevel - 10;
            $tmin = $mLevel->minlevel + 10;
            $params = array(
                'game_id' => $model->game_id,
                'skill_id' => $initStart,
                'start_level' => $tmin,
                'end_level' => $tmax,
                'attack' => '',
                'defence' => 1,
                'strength' => 1
            );
            $oprice = ProductSkill::model()->getSkillLevelPH($params);
            ?>
            <div class="show-level">
                Lv : <input type="text" id="start_level" name="start_level" class="span1" value="<?php echo $tmin ?>" onblur="changeLevel(this)"> 
                - 
                Lv : <input type="text" id="end_level" name="end_level"  class="span1" value="<?php echo $tmax ?>" onblur="changeLevel(this)">
            </div>
            <hr style="margin:10px 0;"/>
            <div id="slider-range"></div>
            <?php
            $this->widget('ext.selectSlider.selectSliderWidget', array(
                'reqUrl' => Yii::app()->createAbsoluteUrl('category/api', array('action' => 'SKILLP', 'game_id' => $model->game_id)),
                'value' => $tmin . "," . $tmax,
                'max' => $mLevel->maxlevel ? $mLevel->maxlevel : 99,
                'min' => $mLevel->minlevel ? $mLevel->minlevel : 0,
                'ptype' => 'SKILL',
            ));
            ?>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">Total Price:</label>
        <div class="controls">
            <input class="span2" disabled id="show_price" value="<?php $tPrice = $this->changeCurrency($oprice['skill_price']); echo implode('', $tPrice); ?>" type="text">
            
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">Hour:</label>
        <div class="controls">
            <input class="span2" disabled type="text" id="show_hour" value="<?php echo round($oprice['skill_time'], 2) ?>" />
        </div>
    </div>
    <div class="pull-right">
        <input rel="add" type="button" class="add-to-cart getAttr btn" value="Add To Cart" id="addtocart">
        <input rel="buy" type="button" class="buy-now getAttr btn btn-primary" value="Buy Now" id="buy_now" >
    </div>
    <div class="clearfix"></div>
</form>

<script>
    $(function(){
        $('#attack_box').attr('disabled', true);
        $('#defence_box').attr('disabled', false);
        $('#strength_box').attr('disabled', false);
        $("#skill").change(function(){
            var skill = this.value
            //$('#attack_box').val('');
            //$('#defence_box').val('');
            //$('#strength_box').val('');
            switch(skill){
                case '26':
                    $('#attack_box').attr('disabled', true);
                    $('#defence_box').attr('disabled', false);
                    $('#strength_box').attr('disabled', false);
                    break;
                case '29':
                    $('#attack_box').attr('disabled', false);
                    $('#defence_box').attr('disabled', true);
                    $('#strength_box').attr('disabled', false);
                    break;
                case '27':
                    $('#attack_box').attr('disabled', false);
                    $('#defence_box').attr('disabled', false);
                    $('#strength_box').attr('disabled', true);
                    break;
                case '30':
                    $('#attack_box').attr('disabled', true);
                    $('#defence_box').attr('disabled', false);
                    $('#strength_box').attr('disabled', true);
                    break;
                default:
                    $('#attack_box').attr('disabled', true);
                    $('#defence_box').attr('disabled', true);
                    $('#strength_box').attr('disabled', true);
            }
        });
    });

    function SetSkillData(){
        var slevel = $("#start_level").val();
        var elevel = $("#end_level").val();
        getAjaxVal(slevel,elevel);
    }
    
</script>